package com.monitor.system.controller;

import com.monitor.common.annotation.Log;
import com.monitor.common.core.controller.BaseController;
import com.monitor.common.core.domain.AjaxResult;
import com.monitor.common.core.page.TableDataInfo;
import com.monitor.common.enums.BusinessType;
import com.monitor.common.utils.page.PagingUtils;
import com.monitor.common.utils.poi.ExcelUtil;
import com.monitor.system.domain.DataBackupDetection;
import com.monitor.system.service.IDataBackupDetectionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 数据备份检测Controller
 * 
 * @author monitor
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/system/detection")
public class DataBackupDetectionController extends BaseController
{
    @Autowired
    private IDataBackupDetectionService dataBackupDetectionService;

    /**
     * 查询数据备份检测列表
     */
    @ApiOperation("查询数据备份检测列表")
    @PreAuthorize("@ss.hasPermi('system:detection:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataBackupDetection dataBackupDetection)
    {
        List<DataBackupDetection> list = dataBackupDetectionService.selectDataBackupDetectionList(dataBackupDetection);
        return PagingUtils.createPageInfoList(list);
    }

    /**
     * 导出数据备份检测列表
     */
    @ApiOperation("导出数据备份检测列表")
    @PreAuthorize("@ss.hasPermi('system:detection:export')")
    @Log(title = "数据备份检测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataBackupDetection dataBackupDetection)
    {
        List<DataBackupDetection> list = dataBackupDetectionService.selectDataBackupDetectionList(dataBackupDetection);
        ExcelUtil<DataBackupDetection> util = new ExcelUtil<DataBackupDetection>(DataBackupDetection.class);
        util.exportExcel(response, list, "数据备份检测数据");
    }

    /**
     * 获取数据备份检测详细信息
     */
    @ApiOperation("获取数据备份检测详细信息")
    @PreAuthorize("@ss.hasPermi('system:detection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataBackupDetectionService.selectDataBackupDetectionById(id));
    }

    /**
     * 新增数据备份检测
     */
    @ApiOperation("新增数据备份检测")
    @PreAuthorize("@ss.hasPermi('system:detection:add')")
    @Log(title = "数据备份检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataBackupDetection dataBackupDetection)
    {
        return toAjax(dataBackupDetectionService.insertDataBackupDetection(dataBackupDetection));
    }

    /**
     * 修改数据备份检测
     */
    @ApiOperation("修改数据备份检测")
    @PreAuthorize("@ss.hasPermi('system:detection:edit')")
    @Log(title = "数据备份检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataBackupDetection dataBackupDetection)
    {
        return toAjax(dataBackupDetectionService.updateDataBackupDetection(dataBackupDetection));
    }

    /**
     * 删除数据备份检测
     */
    @ApiOperation("删除数据备份检测")
    @PreAuthorize("@ss.hasPermi('system:detection:remove')")
    @Log(title = "数据备份检测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dataBackupDetectionService.deleteDataBackupDetectionByIds(ids));
    }
}
